﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web.Mvc;
using ThaireInvestmentWeb.Util;
using ThaireInvestmentWeb.WcfSerivce;

namespace ThaireInvestmentWeb.Models
{
    public class ManageUnitTrustPrivilegeModel
    {
        public UnitTrustHeaderDTO HeaderDTO { get; set; }       
        public UnitTrustHeader Header { get; set; }
        public IList<UnitTrustPrivilege> Privileges  { get; set; }

        public ManageUnitTrustPrivilegeModel()
        {
            if (null == Header)
                Header = new UnitTrustHeader();
            if (Privileges == null)
                Privileges = new List<UnitTrustPrivilege>();        
        }

        public static ManageUnitTrustPrivilegeModel BuildModel(UnitTrustHeaderDTO data)
        {
            var model = new ManageUnitTrustPrivilegeModel {Header = data.Header, HeaderDTO = data};
            if (data.Privileges != null)
                model.Privileges = data.Privileges;
            return model;
        }
        public int HeaderID
        {
            get
            {
                return Header.ID;
            }

            set
            {
                Header.ID = value;
            }
        }

    }
}